package com.example.lemis.web.controller;

import com.example.lemis.model.dto.ClazzQuery;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import com.example.lemis.common.JsonResponse;
import com.example.lemis.service.IClazzService;
import com.example.lemis.model.domain.Clazz;


/**
 *
 *  前端控制器
 *
 *
 * @author lxp
 * @since 2025-06-24
 * @version v1.0
 */
@RestController
@RequestMapping("/api/clazz")
@AllArgsConstructor
public class ClazzController {

    private final Logger logger = LoggerFactory.getLogger( ClazzController.class );

    private final IClazzService clazzService;


    /**
    * 描述：根据Id 查询
    *
    */
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public JsonResponse<Clazz> getById(@PathVariable("id") Long id)throws Exception {
        Clazz clazz = clazzService.getById(id);
        return JsonResponse.success(clazz);
    }

    @GetMapping
    public JsonResponse<?> getClazz(ClazzQuery clazzQuery) throws Exception {
        return JsonResponse.success(clazzService.queryOne(clazzQuery));
    }
}

